home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
tpb4_src.zip
/
NETENTR.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-09-13
|
30KB
|
873 lines
{ TPBoard 4.2 Copyright (c) 1987,88 by Jon Schneider & Rick Petersen
Portions Copyright (c) 1986,87 by Steve Fox and Les Archambault
Last modified :: 7-15-88 1:14 pm
}
{$R-} {Range checking off}
{$B-} {Boolean complete evaluation off}
{$S-} {Stack checking off}
{$I+} {I/O checking on}
{$N-} {No numeric coprocessor}
Unit NetEntr;
Interface
Uses
TPCrt, Dos, Globals, Core1, Core2,
TPSTRING, TPDOS, NetMisc, MsgMove;
procedure fido_mesg_enter(to_ctrl : Char;
to_name : Str36;
old_subject : Str72;
MsgToQuote : Str10;
var last_msg_num : Integer);
{==========================================================================}
Implementation
procedure fido_mesg_enter(to_ctrl : Char;
to_name : Str36;
old_subject : Str72;
MsgToQuote : Str10;
var last_msg_num : Integer);
{ Enter a new message }
type
TextPtr = ^TextRecord;
TextRecord =
record
LineNo : Integer; { Line number }
TextMsg : message; { Summary index }
next : TextPtr { Pointer to next element on list }
end;
Str4 = string[4];
var
stop_msg,
abort, OK,
public, CRLF,
node_entrd,
quote,
attached_file : Boolean;
ch : Char;
low : Byte;
last_line,
high_msg_num,
Number,
remaining : Integer;
TextBase,
TextLast, This : TextPtr;
subj : Str72;
msgnum, reply : Str10;
FidoDrv : Str3;
temp_str : Str4;
offset, nodes,
position : Integer;
Buffer : array[1..512] of Byte;
text_file,
msg_file : untype_file;
subj_prompt,
fido_area : StrStd;
quote_file : Text;
mname : Str13;
msg_line : StrStd;
function In_Conference : Boolean;
var
i : Integer;
This : AreaPtr;
begin
This := AreaBase;
i := 0;
while (This <> nil) and (This^.AreaName <> AreaReq) do
This := This^.next;
if This^.AreaName = AreaReq then
i := This^.AreaConf and 7;
if i = 0 then
In_Conference := True
else
In_Conference := test_bit(user_rec.conf_flags, i);
end;
procedure GetLine(var line : StrStd);
var
position,
character : Byte;
begin
line := ' > ';
position := 4;
repeat
{$I-}
Read(Byte_file, character) {$I+} ;
OK := (IoResult = 0);
if OK and (character <> 0) then
begin
case Chr(character) of
SOH :
repeat
{$I-}
Read(Byte_file, character) {$I+} ;
OK := (IoResult = 0);
until (Chr(character) = CR) or (not OK);
SoftCR, CR, LF :
begin
{do nothing}
end;
TAB :
character := Ord(SPC);
else
begin
line := line+Chr(character);
Inc(position);
end;
end;
end;
until (not OK) or ((position > 58) and (character = Ord(SPC))) or
(position = 70) or (character = Ord(CR));
if (not OK) or (Pos('--- ', line) = 4) or (Pos(' * Origin:', line) = 4) then
line := ''
else
line := line+CR+LF;
end;
procedure fido_mesg_input(var last_line : Integer);
{ Input message }
var
ch : Char;
This : TextPtr;
msg : StrStd;
begin
WriteLn(com);
msg := ' ';
next_inpstr := '';
while (not brk) and (msg <> '') and (Online) do
begin
msg := next_inpstr;
if (last_line+1 = max_msg_lines) and (limit_lines) then
WriteLn(com, 'Two Lines Left');
if (last_line > max_msg_lines) and (limit_lines) then
msg := ''
else
begin
if quote then
GetLine(msg)
else
begin
Write(com, last_line:2, '> ');
GetStr(msg, ch, len_msg, 'AEWH');
WriteLn(com)
end;
end;
if msg <> '' then
if MaxAvail > 400 then
begin
New(This);
if TextBase = nil then
TextBase := This
else
TextLast^.next := This;
TextLast := This;
TextLast^.LineNo := last_line;
TextLast^.TextMsg := msg;
TextLast^.next := nil;
Inc(last_line)
end
else
begin
WriteLn(com, 'Memory full.');
msg := ''
end
end;
end;
procedure fido_mesg_edit;
{ Edit selected line from message }
var
ch : Char;
i : Integer;
This, prev : TextPtr;
msg : StrStd;
begin
WriteLn(com);
Write(com, 'Edit message line...');
i := strint(prompt('Number', 2, 'E'));
This := TextBase;
prev := TextBase;
if i > 0 then
begin
while (i <> This^.LineNo) and (This <> nil) do {find line}
begin
prev := This;
This := This^.next;
end;
if This <> nil then
begin
CRLF := False;
msg := This^.TextMsg;
if Pos(CR, msg) <> 0 then
begin
Delete(msg, Length(msg)-1, 2);
CRLF := True
end;
Write(com, i:2, '> ');
GetStr(msg, ch, len_msg, 'EL');
WriteLn(com);
if msg <> '' then
begin
if CRLF then
msg := msg+CR+LF;
This^.TextMsg := msg
end;
end
else
WriteLn(com, 'Not found.')
end; {i>0}
end;
procedure fido_mesg_delete;
{ Delete selected lines from message }
var
i, n : Integer;
This, prev : TextPtr;
begin
WriteLn(com);
i := strint(prompt('Delete line number', 3, 'E'));
n := strint(prompt(' through number', 3, 'E'))+1;
if n > last_line then
n := last_line;
n := n-i;
if (i > 0) and (n > 0) then
repeat
This := TextBase;
prev := TextBase;
while (i <> This^.LineNo) and (This <> nil) do {find line}
begin
prev := This;
This := This^.next;
end;
if This <> nil then
begin
if (prev = TextBase) and (prev = This) then
TextBase := This^.next
else
prev^.next := This^.next;
Dispose(This);
if TextLast = This then
TextLast := prev;
This := prev^.next;
while This <> nil do
begin
This^.LineNo := Pred(This^.LineNo);
TextLast := This;
This := This^.next;
end;
Dec(last_line);
Dec(n);
end
else
begin
WriteLn(com, 'Not found.');
n := 0
end;
until n = 0; {i>0}
end;
procedure fido_mesg_insert_line;
{modified by ret -- 7/24/88}
var
ch : Char;
i, line_count : Integer;
This, prev, new_line : TextPtr;
msg : StrStd;
begin
WriteLn(Com);
i := strint(prompt('Insert before line...Number', 2, 'E'));
This := TextBase;
prev := TextBase;
if i > 0 then
begin
while (i <> This^.LineNo) and (This <> nil) do {find line}
begin
prev := This;
This := This^.next;
end;
if This <> nil then
begin
if (prev = TextBase) and (prev = This) then
TextBase := nil {inserting at very beginning}
else
TextLast := prev; {end of top part of break}
line_count := i; {save line count to current line}
fido_mesg_input(i); {insert (input) new lines}
TextLast^.next := This; {connect tail of mesg to
the newly inserted lines}
line_count := i-line_count; {calculate # of new lines}
while This <> nil do
begin
This^.LineNo := This^.LineNo+line_count;
TextLast := This;
This := This^.next;
end;
Last_line := Last_line+line_count {update total line count}
end
else
WriteLn(Com, 'Not found.')
end; {i>0}
end;
procedure fido_mesg_print;
{ Display message currently being edited }
var
This : TextPtr;
msg : StrStd;
begin
WriteLn(com);
WriteLn(com, 'From: ', UserFullName);
st := to_name;
caps_to_mixed(st);
WriteLn(com, ' To: ', st, ' ', msg_hdr.dest_net,
'/', msg_hdr.dest_node);
WriteLn(com, ' Re: ', subj);
WriteLn(com);
This := TextBase;
while (not brk) and (This <> nil) do
begin
msg := This^.TextMsg;
if Pos(CR, msg) <> 0 then
Delete(msg, Length(msg)-1, 2);
if (Pos(' > ', msg) = 1) then
WriteLn(com, This^.LineNo:2, ':', msg)
else
WriteLn(com, This^.LineNo:2, ': ', msg);
This := This^.next
end
end;
procedure fido_mesg_save(subj : Str72;
var stop_msg : Boolean);
{ Save message to disk }
var
i : Integer;
This : TextPtr;
file_time : tad_array;
Str : Str20;
subj_str : Str72;
OK : Boolean;
msg_footer : string;
begin
WriteLn(com);
if AreaReq[1] <> '-' then
begin
user_rec.acct_bal := user_rec.acct_bal-node_hdr.node_cost;
if ask('Do you want this message to be public', 'N') then
begin
clear_bit(low, 0);
public := True;
end
else public := False;
if user_rec.access > 250 then
begin
if ask('Kill after mailing', 'N') then
set_bit(low, 7);
if ask('Send via Crash mail', 'Y') then
set_bit(low, 1)
end
end
else
begin
clear_bit(low, 0);
public := True
end;
GetTAD(file_time);
Str := Fido_FormTAD(file_time);
with msg_hdr do
begin
FillChar(msg_from, 36, 0);
FillChar(msg_to, 36, 0);
FillChar(subject, 72, 0);
FillChar(date, 20, 0);
times := 0;
orig_node := this_node;
cost := node_hdr.node_cost;
orig_net := this_net;
prev_msg := $00;
attr_low := low;
attr_high := $01;
next_msg := $00;
Move(UserFullName[1], msg_from, Length(UserFullName));
{$V-}
caps_to_mixed(to_name) {$V+} ;
Move(to_name[1], msg_to, Length(to_name));
subj_str := subj;
Move(subj_str[1], subject, Length(subj_str));
Move(Str[1], date, Length(Str));
end;
SetSect(fido_area);
Assign(fido_file, msgnum+'.MSG');
{$I-}
Rewrite(fido_file) {$I+} ;
OK := (IoResult = 0);
if OK then
begin
Write(fido_file, msg_hdr);
Close(fido_file);
Assign(fido_message, msgnum+'.TXT');
{$I-}
Rewrite(fido_message) {$I+} ;
OK := (IoResult = 0);
if OK then
begin
This := TextBase;
while This <> nil do
begin
Write(fido_message, This^.TextMsg);
if Pos(LF, This^.TextMsg) = 0 then
Write(fido_message, ' ');
This := This^.next
end;
Close(fido_message);
Assign(msg_file, msgnum+'.MSG');
{$I-}
Reset(msg_file, 1) {$I+} ;
OK := (IoResult = 0);
if OK then
begin
Seek(msg_file, FileSize(msg_file));
Assign(text_file, msgnum+'.TXT');
{$I-}
Reset(text_file, 1) {$I+} ;
OK := (IoResult = 0);
if OK then
begin
remaining := 512;
while remaining = 512 do
begin
BlockRead(text_file, Buffer, 512, remaining);
BlockWrite(msg_file, Buffer, remaining);
end;
if AreaReq[1] = '-' then
begin
msg_footer := tear_line+sect_orig+seenby_line;
for i := 1 to Length(msg_footer) do
Buffer[i] := Ord(msg_footer[i]);
BlockWrite(msg_file, Buffer, Length(msg_footer));
end;
for i := 1 to 5 do
Buffer[i] := 0;
BlockWrite(msg_file, Buffer, 5);
Close(msg_file);
Close(text_file);
Erase(text_file)
end;
end;
end;
end;
if OK then
begin
WriteLn(com);
if public then
Write(com, 'Public')
else
Write(com, 'Private');
WriteLn(com, ' message ', msgnum, ' filed ', Str);
if AreaReq[1] <> '-' then
NetMsgEntr := 1
else
EchoMsgEntr := 2;
if to_ctrl = 'R' then
Inc(last_msg_num);
end
else
WriteLn(com, 'Message not filed due to I/O problems.');
stop_msg := True;
SetSect(HomName);
end;
procedure fido_mesg_quit(var stop_msg : Boolean);
{ Return to command mode }
begin
WriteLn(com);
WriteLn(com, 'Message not filed.');
stop_msg := True;
mult_cmds := False;
Cmd_Queue := '';
end;
function open_quote_msg : Boolean;
begin
Assign(Byte_file, MsgToQuote+'.MSG');
{$I-}
Reset(Byte_file) {$I+} ;
OK := (IoResult = 0);
if OK then
begin
{$I-}
Seek(Byte_file, 190) {$I+} ;
open_quote_msg := (IoResult = 0)
end
else
open_quote_msg := False;
end;
begin {message enter}
if AreaReq = 'NETMAIL' then
fido_area := fidomail
else
fido_area := fidomail+'\'+AreaReq;
mname := AreaReq;
if Pos('-', mname) = 1 then
Delete(mname, 1, 1);
mname := Copy(mname, 1, 8)+'.MSG';
abort := False;
attached_file := False;
low := 1;
SetSect(fidolists);
OK := ExistFile(netlist) and ExistFile(nodelist);
SetSect(HomName);
if (not OK) then
begin
WriteLn(com);
WriteLn(com, 'Can''t find Node List files, aborting...')
end
else if (AreaReq = 'NETMAIL') and (not In_Conference) then
list('H')
else if user_rec.access < val_acc then
list('D')
else
begin
if to_ctrl <> 'R' then
fido_sort(high_msg_num, Number, msg_numbers)
else
begin
high_msg_num := last_msg_num;
quote := ask('Quote message', 'N')
end;
WriteLn(com);
Inc(high_msg_num);
Str(high_msg_num, msgnum);
FidoDrv := Copy(fidomail, 1, 3);
if (diskfree(Ord(Upcase(FidoDrv[1]))-64) div 1024) > maxfree_abs then
begin
if (diskfree(Ord(Upcase(FidoDrv[1]))-64) div 1024) <= maxfree_mslimit then
begin
limit_lines := True;
max_msg_lines := maxfree_lines;
end;
if to_ctrl <> 'R' then
begin
abort := False;
WriteLn(com);
to_name := '';
if (user_rec.access >= 250) and (AreaReq = 'NETMAIL') then
begin
if (ask('Attach File', 'N')) then
begin
WriteLn(com);
subj := prompt(' File: ', 71, 'EL');
if ExistFile(subj) then
begin
if Pos('\', subj) = 0 then
begin
abort := True;
WriteLn(com);
WriteLn(com, 'Full path name must be specified, aborting..')
end
else
begin
set_bit(low, 4);
attached_file := True;
end;
end
else
begin
abort := True;
WriteLn(com);
WriteLn(com, 'Couldn''t find file, aborting..')
end;
end;
WriteLn(com);
end;
if (not abort) then
begin
WriteLn(com, ' From: ', UserFullName);
to_name := prompt(' To: ', 35, 'EL');
to_name := StUpcase(to_name);
if to_name = '' then
to_name := 'All';
end;
if (not abort) and (not test_bit(low, 4)) then
subj := prompt('Subject: ', 71, 'EL');
WriteLn(com);
if subj = '' then
subj := '...';
if (not abort) and (AreaReq[1] <> '-') then
begin
repeat
node_entrd := False;
repeat
reply := prompt('Net (or CR for List) ', 9, 'ES');
if reply = '?' then
reply := ' ';
if reply = ' ' then
begin
show_nets;
WriteLn(com);
WriteLn(com)
end;
until (reply <> ' ') or (not Online);
position := Pos('/', reply);
if position <> 0 then
begin
temp_str := Copy(reply, Succ(position), 4);
msg_hdr.dest_node := strint(temp_str);
Delete(reply, position, 5);
node_entrd := True
end;
msg_hdr.dest_net := strint(reply);
check_net(msg_hdr.dest_net, offset, nodes, OK);
if (not OK) and (msg_hdr.dest_net <> 0) then
begin
WriteLn(com, 'No such Net, try again.');
node_entrd := False
end;
abort := (msg_hdr.dest_net = 0);
until OK or (not Online) or abort;
repeat
if (not node_entrd) then
begin
repeat
reply := prompt('Node (CR for List) ', 4, 'ES');
if reply = '?' then
reply := ' ';
if (reply = ' ') then
begin
show_nodes(offset, nodes);
WriteLn(com);
WriteLn(com)
end;
until ((reply <> ' ') and (reply[1] in ['0'..'9']))
or (not Online);
msg_hdr.dest_node := strint(reply);
end;
check_node(msg_hdr.dest_node, offset, nodes, OK);
if (not OK) then
begin
WriteLn(com, 'No such Node, try again.');
node_entrd := False
end;
until OK or (not Online);
end;
if AreaReq[1] = '-' then
node_hdr.node_cost := 0;
if (node_hdr.node_cost > user_rec.acct_bal) and (not abort) then
begin
list('H');
abort := True
end;
end
else
begin
abort := False;
msg_hdr.dest_net := msg_hdr.orig_net;
msg_hdr.dest_node := msg_hdr.orig_node;
if AreaReq[1] <> '-' then
begin
check_net(msg_hdr.dest_net, offset, nodes, OK);
if OK then
begin
check_node(msg_hdr.dest_node, offset, nodes, OK);
if node_hdr.node_cost > user_rec.acct_bal then
begin
list('H');
abort := True
end;
end;
end
else
begin
OK := True;
node_hdr.node_cost := 0
end;
if OK and (not abort) then
begin
subj_prompt := old_subject;
WriteLn(com, 'From: ', UserFullName);
WriteLn(com, ' To: ', to_name);
Write(com, ' Re: ');
GetStr(subj_prompt, ch, 72, 'EL');
subj := subj_prompt;
WriteLn(com)
end
else if (not abort) then
begin
WriteLn(com, 'Couldn''t locate the senders Node. Aborting....');
abort := True
end;
end;
if OK and (not abort) then
begin
WriteLn(com);
if limit_lines then
begin
WriteLn(com, 'Message is limited to ', max_msg_lines, ' lines.');
WriteLn(com);
end;
WriteLn(com, 'When Message finished, enter an empty line. <CR>');
WriteLn(com, 'Ready for message...');
TextBase := nil;
last_line := 1;
SetSect(fido_area);
if quote then
begin
quote := open_quote_msg;
if quote and local_online then
begin
SetSect(HomName);
Assign(quote_file, mname);
Rewrite(quote_file);
SetSect(fido_area);
next_inpstr := '';
msg_line := ' ';
while (not brk) and (msg_line <> '') and (Online) do
begin
msg_line := next_inpstr;
GetLine(msg_line);
if msg_line <> '' then
begin
SetSect(HomName);
Write(quote_file, msg_line);
SetSect(fido_area);
end
end;
SetSect(HomName);
Close(quote_file);
SetSect(fido_area);
end;
end;
if (not local_online) then
fido_mesg_input(last_line);
if quote then
Close(Byte_file);
if local_online then
make_fido_message(AreaReq, '', user_loc, 0, subj, True,
to_name, msg_hdr.dest_net, msg_hdr.dest_node, attached_file);
SetSect(HomName);
stop_msg := False;
if TextBase <> nil then
begin
repeat
WriteLn(com);
if quote then
begin
st := 'L';
quote := False
end
else
st := prompt('Edit command <C><D><E><I><L><S><Q><?>', 80, 'ES?');
if Length(st) = 1 then
ch := st[1]
else
st := ' ';
case ch of
'C' :
fido_mesg_input(last_line);
'D' :
begin
fido_mesg_delete;
fido_mesg_print;
end;
'E' :
fido_mesg_edit;
'I' :
begin
fido_mesg_insert_line;
fido_mesg_print;
end;
'L' :
fido_mesg_print;
'S' :
begin
if (AreaReq[1] <> '-') and (node_hdr.node_cost > 0) then
begin
WriteLn(com);
Write(com, 'This message will cost ',
node_hdr.node_cost, ' cents. ');
if ask('Do you want to send it', 'Y') then
fido_mesg_save(subj, stop_msg)
else
fido_mesg_quit(stop_msg);
end
else
fido_mesg_save(subj, stop_msg)
end;
'Q' :
fido_mesg_quit(stop_msg)
else
list('E');
end;
until (not Online) or (stop_msg and (ch in ['C', 'D', 'E', 'I', 'L',
'S', 'Q']));
end
else if (not local_online) then
WriteLn(com, 'Unable to continue message - aborting. ');
while TextBase <> nil do
begin
This := TextBase; { Get rid of list elements }
TextBase := TextBase^.next;
Dispose(This)
end;
end; {OK}
end {enough disk space and allowed}
else
begin
if test_bit(user_rec.flags, 4) then
WriteLn(com, 'Unable to accept messages.')
else
WriteLn(com, 'Not enough disk space for messages.');
end;
end;
end;
end. { of NETENTR.PAS}